<?php

namespace addons\member\model;
/**
 * 反馈表
 * Class SysFeedback
 * @package addons\member\model
 */

class SysFeedback extends \web\common\model\BaseModel {

    protected function _initialize() {
        $this->tableName = 'sys_feedback';
    }

    public function getFeedbackList($pageIndex = -1, $pageSize = -1, $filter = '', $order = 'a.id desc') {
        $sql = 'select a.*,b.username,b.phone from ' . $this->getTableName()  . ' AS  a LEFT JOIN tp_member_account AS b ON a.user_id = b.id';
        if (!empty($filter)) {
            $sql = $sql . ' where ' . $filter;
        }
        return $this->getDataListBySQL($sql, $pageIndex, $pageSize, $order);
    }

    /**
     * 获取记录总数
     * @param type $filter
     * @return int
     */
    public function getFeedbackTotal($filter = '') {
        $sql = 'select count(*) as c from  ' . $this->getTableName()  . ' AS  a LEFT JOIN tp_member_account AS b ON a.user_id = b.id';
        if (!empty($filter))
            $sql .= ' where ' . $filter;
        $result = $this->query($sql);

        if (count($result) > 0)
            return intval($result[0]['c']);
        else
            return 0;
    }
   
    
}
